package net.vinote.smart.platform.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.vinote.smartweb.client.UserServiceClient;
import net.vinote.smartweb.service.facade.UserInfoService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class BaseController {
	@Autowired
	private UserInfoService userInfoService;

	@Autowired
	private UserServiceClient userServiceClient;

	@RequestMapping("/index.html")
	public ModelAndView viewContract(HttpServletRequest request,
			HttpServletResponse response) {

		ModelAndView mav = new ModelAndView("index");
		mav.addObject("result", userInfoService.query(1));
		mav.addObject("result1", userServiceClient.query(1));
		System.out.println(userServiceClient.query(1));
		return mav;
	}

	@RequestMapping("/index.htm")
	public ModelAndView viewContract1(HttpServletRequest request,
			HttpServletResponse response) {

		ModelAndView mav = new ModelAndView("index");
		mav.addObject("result", userInfoService.query(1));
		mav.addObject("result1", userServiceClient.query(1));
		System.out.println(userServiceClient.query(1));
		return mav;
	}

	@RequestMapping("/index.xml")
	public ModelAndView viewCon1tract1(HttpServletRequest request,
			HttpServletResponse response) {

		ModelAndView mav = new ModelAndView("index");
		mav.addObject("result", userInfoService.query(1));
		System.out.println(userServiceClient.query(1));
		return mav;
	}

	@RequestMapping("/index.json")
	public ModelAndView getJson(HttpServletRequest request,
			HttpServletResponse response) {

		ModelAndView mav = new ModelAndView("index");
		mav.addObject("result", userInfoService.query(1));
		mav.addObject("result1", userServiceClient.query(1));
		System.out.println(userServiceClient.query(1));
		return mav;
	}
}
